using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using Volo.Abp.Domain.Repositories;
using AuthService.Domain.Security;

namespace AuthService.Security;

/// <summary>
/// 风险评估仓储接口
/// </summary>
public interface IRiskAssessmentRepository : IRepository<RiskAssessment, Guid>
{
    /// <summary>
    /// 获取用户的风险评估列表
    /// </summary>
    Task<List<RiskAssessment>> GetByUserIdAsync(Guid userId, CancellationToken cancellationToken = default);

    /// <summary>
    /// 获取用户最近的评估
    /// </summary>
    Task<RiskAssessment> GetLatestByUserIdAsync(Guid userId, string actionType, CancellationToken cancellationToken = default);

    /// <summary>
    /// 获取高风险评估列表
    /// </summary>
    Task<List<RiskAssessment>> GetHighRiskAssessmentsAsync(Guid? tenantId, CancellationToken cancellationToken = default);

    /// <summary>
    /// 获取指定时间范围内的评估
    /// </summary>
    Task<List<RiskAssessment>> GetByDateRangeAsync(DateTime startTime, DateTime endTime, CancellationToken cancellationToken = default);

    /// <summary>
    /// 获取用户指定操作类型的评估历史
    /// </summary>
    Task<List<RiskAssessment>> GetByUserIdAndActionTypeAsync(Guid userId, string actionType, int maxCount = 10, CancellationToken cancellationToken = default);

    /// <summary>
    /// 获取评估列表（分页）
    /// </summary>
    Task<List<RiskAssessment>> GetListAsync(string filter = null, string riskLevel = null, int maxResultCount = 10, int skipCount = 0, CancellationToken cancellationToken = default);

    /// <summary>
    /// 获取评估总数
    /// </summary>
    Task<long> GetCountAsync(string filter = null, string riskLevel = null, CancellationToken cancellationToken = default);

    /// <summary>
    /// 删除过期的评估记录
    /// </summary>
    Task<int> DeleteExpiredAssessmentsAsync(DateTime expireDate, CancellationToken cancellationToken = default);
}